package com.immediatus.graphics.factories;

import android.content.Context;
import android.graphics.Typeface;
import com.immediatus.graphics.contracts.ITexture;
import com.immediatus.graphics.font.Font;
import com.immediatus.graphics.font.StrokeFont;

public class FontFactory{
    private static String _assetBasePath = "";

    public static void setAssetBasePath(final String assetBasePath_){
        if (assetBasePath_.endsWith("/") || assetBasePath_.length() == 0){
            FontFactory._assetBasePath = assetBasePath_;
        } else{
            throw new IllegalStateException("wrong assetBasePath");
        }
    }

    public static void reset(){
        FontFactory.setAssetBasePath("");
    }

    public static Font create(final ITexture tex_, final Typeface typeface_, final float size_, final boolean antiAlias_, final int color_){
        return new Font(tex_, typeface_, size_, antiAlias_, color_);
    }

    public static StrokeFont createStroke(final ITexture tex_, final Typeface typeface_, final float size_, final boolean antiAlias_, final int color_, final float strokeWidth_, final int strokeColor_){
        return new StrokeFont(tex_, typeface_, size_, antiAlias_, color_, strokeWidth_, strokeColor_);
    }

    public static StrokeFont createStroke(final ITexture tex_, final Typeface typeface_, final float size_, final boolean antiAlias_, final int color_, final float strokeWidth_, final int strokeColor_, final boolean strokeOnly_){
        return new StrokeFont(tex_, typeface_, size_, antiAlias_, color_, strokeWidth_, strokeColor_, strokeOnly_);
    }

    public static Font createFromAsset(final ITexture tex_, final Context context_, final String assetPath_, final float size_, final boolean antiAlias_, final int color_){
        return new Font(tex_, Typeface.createFromAsset(context_.getAssets(),
                FontFactory._assetBasePath + assetPath_), size_, antiAlias_, color_);
    }

    public static StrokeFont createStrokeFromAsset(final ITexture tex_, final Context context_, final String assetPath_, final float size_, final boolean antiAlias_, final int color_, final float strokeWidth_, final int strokeColor_){
        return new StrokeFont(tex_, Typeface.createFromAsset(context_.getAssets(),
                FontFactory._assetBasePath + assetPath_), size_, antiAlias_, color_, strokeWidth_, strokeColor_);
    }

    public static StrokeFont createStrokeFromAsset(final ITexture tex_, final Context context_, final String assetPath_, final float size_, final boolean antiAlias_, final int color_, final float strokeWidth_, final int strokeColor_, final boolean strokeOnly_){
        return new StrokeFont(tex_, Typeface.createFromAsset(context_.getAssets(), FontFactory._assetBasePath +
                assetPath_), size_, antiAlias_, color_, strokeWidth_, strokeColor_, strokeOnly_);
    }
}
